package it.unical.canonaco.rende.igpe.game.cbv.logiclayer.engine.component.pawn.items;

import it.unical.canonaco.rende.igpe.game.cbv.logiclayer.engine.component.pawn.stats.Stats;

public class Item extends Stats implements Comparable{

	/**
	 * toString returns only the item name (jtree with default renderer
	 * takes also an object and display the label through "toString" method,
	 * hence toString returns exactly the key of the item, that is the name of the item).
	 */
	@Override
	public String toString() {
		return  name ;
	}

	private float buyPrice = 0;
	private float sellPrice = 0;
	private String name;
	
	public Item() {
	  super();
	}

	public float getBuyPrice() {
		return buyPrice;
	}

	public void setBuyPrice(float buyPrice) {
		this.buyPrice = buyPrice;
	}

	public float getSellPrice() {
		return sellPrice;
	}

	public void setSellPrice(float sellPrice) {
		this.sellPrice = sellPrice;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	final int SMALLER = -1;
	final int EQUAL = 0;
	final int BIGGER = 1;
	/**
	 *  Items are compared based on purchase price.
	 */
	@Override
	public int compareTo(Object obj) {
	
		if( this == obj) return EQUAL;
		final Item item = (Item) obj;
		if(this.buyPrice < item.buyPrice)
			return SMALLER;
		return BIGGER;
	}

}
